﻿using AutoMapper;
using Tauren.Business.Entity.Const;

namespace Tauren.Business.Mapper
{
    public class AccountProfile : Profile, ICommProfile
    {
        public AccountProfile()
        {
            InitProfile();
        }

        /// <summary>
        /// 初始化Mapper
        /// </summary>
        public void InitProfile()
        {
            CreateMap<Entity.Model.AccoutInfo, Entity.Output.AccoutInfo_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
            CreateMap<Entity.Input.AccoutInfo_Input, Entity.Model.AccoutInfo>();
            CreateMap<Entity.Model.PageAccountModel, Entity.Global.AccountListModel>().AfterMap((data, view) =>
            {
                view.Account = data.Account;
                view.AccountId = data.AutoId;
                view.EmpId = data.EmpId;
                view.Name = data.Name;
                view.OrgId = data.OrgId;
                view.RowNo = data.RowNo;
            });
        }
    }
}
